package com.mlm.mlmapp.adapter.view.listener;

import android.content.Context;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.androidquery.AQuery;
import com.flyco.dialog.widget.base.BaseDialog;
import com.mlm.mlmapp.R;
import com.mlm.mlmapp.adapter.view.MyListView;
import com.mlm.mlmapp.cons.HTTPCons;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class VersionCheckDialog extends BaseDialog implements HTTPCons {
	private Context mContext;
	private int layout;
	MyListView items;
	List<JSONObject> list = new ArrayList<JSONObject>();
	AQuery aq;
	TextView apply;
	TextView cancel;
	TextView sub_title;
	HashMap<String, String> map = new HashMap<>();
	DialogListener l;
	TextView versionName;
	String vn;
	String title;
	public VersionCheckDialog(Context context, DialogListener l, String title,String vn) {
		super(context);
		// TODO Auto-generated constructor stub
		this.mContext = context;
		this.l = l;
		this.title = title;
		this.vn=vn;
		aq = new AQuery(context);
	}

	@Override
	public View onCreateView() {
		// TODO Auto-generated method stub
		this.setCanceledOnTouchOutside(true);
		View inflate = View.inflate(context, R.layout.version_check_dialog, null);
		sub_title=(TextView) inflate.findViewById(R.id.sub_title);
		versionName=(TextView) inflate.findViewById(R.id.version_name);
		sub_title.setText(Html.fromHtml(title));
		versionName.setText(Html.fromHtml(vn));
		apply = (TextView) inflate.findViewById(R.id.apply);
		cancel = (TextView) inflate.findViewById(R.id.cancel);
		apply.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				VersionCheckDialog.this.dismiss();
				l.onApply(null,null);
			}
		});
		cancel.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				VersionCheckDialog.this.dismiss();
				l.onCancel();
			}
		});
		return inflate;
	}

	public void setLayout(int layout) {
		this.layout = layout;
	}
	@Override
	public boolean setUiBeforShow() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onBackPressed() {

	}
}
